#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		char d;
		cin >> n >> d;
		string s;
		cin >> s;
		for (int i = 0; i < n; i++)
		{
			if (s[i] < d)
			{
				s.insert(i, 1, d);
				break;
			}
		}
		if (s.size() == n) s += d;
		cout << s << endl;
	}
	return 0;
}